// 处理时间格式
function timeTrans(time, type) {
  let date = new Date(new Date(time).getTime() + 8 * 3600 * 1000);
  date = date.toJSON();
  if (type === 1) {
    date = date.substring(0, 10);
  } else {
    date = date.substring(0, 19).replace("T", " ");
  }
  return date;
}
// 处理金额格式化
function formatPrice(price) {
  return String(price)
      .split('')
      .reverse()
      .reduce((prev, next, index) => {
        return (index % 3 ? next : next + ',') + prev;
      });
}

module.exports = {
  timeTrans,
  formatPrice
};
